#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<stack>
#include<vector>
#include <cstddef>
using namespace std;
class Solution 
{
public:
    bool IsPopOrder(vector<int>& pushV, vector<int>& popV)
    {
        stack<int> tmp;
        size_t length = pushV.size();
        size_t pindex = 0;
        for (size_t i = 0;i < length;i++)
        {
            tmp.push(pushV[i]);
            while (!tmp.empty())
            {
                if (tmp.top() == popV[pindex])
                {
                    tmp.pop();
                    pindex++;
                }
                else {
                    break;
                }
            }
        }
        if (tmp.empty())
        {
            return true;
        }
        else {
            return false;
        }
    }
};

